import { Component } from '@angular/core';
import {SelfHttp} from "../../services/http/service";
import {SiteService} from "../../services/site/site.service";

@Component({
  selector: 'app-change-site',
  templateUrl: './change-site.component.html',
  styleUrl: './change-site.component.scss',
  providers: [SelfHttp, SiteService]
})
export class ChangeSiteComponent {
  siteList: any = [];
  constructor(private http: SelfHttp, private site: SiteService) {
  }
  ngOnInit() {
    this.site.getSiteList(res => {
      this.siteList = res;
    });
  }
  changeSite(siteId: number | string){
    this.site.changeSite(siteId, res => {
      // 判断当前路由是否包含content
      if(window.location.href.indexOf('content') > -1){
        window.location.href = '/content';
      }else{
        window.location.reload();
      }
    });
  }
}
